package javaLearning.时间;

import java.text.DecimalFormat;
import java.time.Duration;
import java.time.LocalDateTime;

/**
 * 时间相关计算
 *
 * @author luokexiong
 * @version 1.0 2021/2/22
 */
public class TimeCompute {

    public static void main(String[] args) {
        LocalDateTime begin = LocalDateTime.of(2021, 2, 3, 9, 0, 0);
        LocalDateTime end = LocalDateTime.of(2021, 2, 3, 18, 30, 0);

        Duration between = Duration.between(begin, end);
        long days = between.toDays();
        long minutes = between.toMinutes();
        DecimalFormat decimalFormat = new DecimalFormat("#.#");
        System.out.println(days);
        System.out.println(decimalFormat.format((float) minutes / 60));
    }
}
